package com.yonyou.brigade.order_center.service.impl;

import com.yonyou.brigade.order_center.model.BriHotelOrder;
import com.yonyou.brigade.order_center.model.BriHotelRoom;
import com.yonyou.brigade.order_center.model.api.BriHotelOrderInfoAPIDTO;
import com.yonyou.brigade.order_center.service.IBriHotelOrderInfoAPIService;
import com.yonyou.brigade.order_center.service.IBriHotelOrderService;
import com.yonyou.brigade.order_center.service.IBriHotelRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/31.
 */
@Service
public class BriHotelOrderInfoAPIServiceImpl implements IBriHotelOrderInfoAPIService{

    @Autowired
    @Qualifier("briHotelOrderServiceImpl")
    private IBriHotelOrderService briHotelOrderService;

    @Autowired
    @Qualifier("briHotelRoomServiceImpl")
    private IBriHotelRoomService briHotelRoomService;

    @Override
    public List<BriHotelOrderInfoAPIDTO> getBriHotelOrderInfoAPIDTOS(Map params) {
        List<BriHotelOrderInfoAPIDTO> briFlightOrderInfoAPIDTOs = new ArrayList<>();
        List<BriHotelOrder> briHotelOrders = briHotelOrderService.getBriHotelOrder(params);
        for (BriHotelOrder briHotelOrder : briHotelOrders){
            BriHotelOrderInfoAPIDTO briHotelOrderInfoAPIDTO = new BriHotelOrderInfoAPIDTO();
            briHotelOrderInfoAPIDTO.setBriHotelOrder(briHotelOrder);
            List<BriHotelRoom> briHotelRooms = briHotelRoomService.getBriHotelRoom(briHotelOrder.getOrderNo());
            briHotelOrderInfoAPIDTO.setBriHotelRooms(briHotelRooms);
            briFlightOrderInfoAPIDTOs.add(briHotelOrderInfoAPIDTO);
        }
        return briFlightOrderInfoAPIDTOs;
    }
}